#include "Armor.h"
#include <iomanip>

Armor::Armor(std::string name, int mana, int stamina, int hp, int def, int magdef):
Item(name, mana, stamina, hp, magdef),
def(def)
{
}

std::vector<int> Armor::getModifiers()
{
	std::vector<int> ret = {0, def, 0, maxMana, maxHP, maxStamina, magDef};
	return ret;
}

void Armor::printInfo(std::string prefix)
{
	if(prefix.empty())
	{
		prefix = "Armor name";
	}
	int column_length = name.size() + 1;
	if(column_length < 5) { column_length = 5;} // TODO maybe lambda function

	int max_length = 15;
	
	int prefix_length = prefix.size();
	if(prefix_length < max_length){
		 for(int i=0;i<max_length-prefix_length;i++){ prefix += ' '; };
		 prefix_length = max_length;
	}
		
	std::cout << std::left << std::setw(column_length) << prefix       << ": " << std::setw(column_length) << name       << std::endl; //TODO print attributes
	if(maxMana > 0)
	{
		std::cout << std::left << std::setw(column_length) << "Maximal Mana   " << ": " << std::setw(column_length) << maxMana    << std::endl;
	}
	if(def > 0)
	{
		std::cout << std::left << std::setw(column_length) << "Defence Points " << ": " << std::setw(column_length) << def    << std::endl;
	}
	if(maxStamina > 0)
	{
		std::cout << std::left << std::setw(column_length) << "Maximal Stamina" << ": " << std::setw(column_length) << maxStamina << std::endl;
	}
	if(maxHP > 0)
	{
		std::cout << std::left << std::setw(column_length) << "Maximal HP     " << ": " << std::setw(column_length) << maxHP      << std::endl;
	}
	if(magDef > 0)
	{
		std::cout << std::left << std::setw(column_length) << "Magic Defence  " << ": " << std::setw(column_length) << magDef     << std::endl;
	}
}
